<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
		<title>Flotr: Basic Legend Example</title>
		<link rel="stylesheet" href="style.css" type="text/css" />
		<!--[if IE]><script type="text/javascript" src="../../flotr/mootools/lib/excanvas.js"></script><![endif]-->
		<script type="text/javascript" src="../../flotr/mootools/lib/mootools-release-1.11.js"></script>
		<script type="text/javascript" src="../../flotr/mootools/flotr.js"></script>
		<style type="text/css">
			.flotr-legend{
				border: 2px solid #B6D9FF;
			}			
		</style>
	</head>
	<body>
		
		<!-- ad -->
		
		<div id="wrapper">
			<h1>Flotr: Basic Legend Example</h1>
			<div id="container" style="width:600px;height:300px;"></div>
			<h2>Example</h2>
			<p>This example shows how to configure the legend. Note I also added a <code>style</code> tag 
			(between the <code>header</code> tags) to add a 2px border to the legend container. I could also
			style other legend elements. The elements get the the following css classes when they're generated:</p>
			<ul>
				<li>flotr-legend &rarr; Legend wrapper element.</li>
				<li>flotr-legend-bg &rarr; Legend background element.</li>
				<li>flotr-legend-color-box &rarr; Legend color box.</li>
				<li>flotr-legend-label &rarr; Legend label.</li>
			</ul>
			<p>Finished? Go to the example <a href="index.html" title="Flotr Example Index Page">index page</a> or the <a href="http://www.solutoire.com/flotr/docs/" title="Flotr Documentation Pages">Flotr Documentation Pages</a>.</p>
			<h2>The Code</h2>
			<pre><code class="javascript">/**
 * This function prepend each label with 'y = '.
 */
function myLabelFunc(label){
	return 'y = ' + label;
}

var f = Flotr.draw(
	$('container'), [ 
		{data:d1, label:'x + sin(x + &pi;)'},
		{data:d2, label:'x'},
		{data:d3, label:'15 - cos(x)'}											
	],{
		legend:{
			position: 'se', // => position the legend 'south-east'.
			labelFormatter: myLabelFunc, // => format the labels.
			backgroundColor: '#D2E8FF' // => a light blue background color.
		}
	}
);</code></pre>
			<div id="footer">Copyright &copy; 2008 Bas Wenneker, <a href="http://www.solutoire.com">solutoire.com</a></div>
		</div>	
		
		<!-- ad -->
			
		<script type="text/javascript">
			/**
			 * Wait till dom's finished loading.
			 */
			window.addEvent('domready', function(){
				/**
				 * Fill series d1 and d2.
				 */
				var d1 = [];
				var d2 = [];
				var d3 = [];
			    for(var i = 0; i < 15; i += 0.5){
			        d1.push([i, i + Math.sin(i+Math.PI)]);
					d2.push([i, i]);
					d3.push([i, 15-Math.cos(i)]);
				}
			
				/**
				 * This function prepend each label with 'y = '.
				 */
				function myLabelFunc(label){
					return 'y = ' + label;
				}
			
				/**
				 * Draw the graph.
				 */
			    var f = Flotr.draw(
					$('container'), [ 
						{data:d1, label:'x + sin(x+&pi;)'},
						{data:d2, label:'x'},
						{data:d3, label:'15 - cos(x)'}											
					],{
						legend:{
							position: 'se', // => position the legend 'south-east'.
							labelFormatter: myLabelFunc, // => format the labels.
							backgroundColor: '#D2E8FF' // => a light blue background color.
						}
					}
				);
			});			
		</script>
		
		<!-- analytics -->
		
	</body>
</html>
